//
//  CommandView_LeftBtn.m
//  TY-C
//
//  Created by xyyl on 2024/3/4.
//

#import "CommandView_LeftBtn.h"
///65*2   30*2
@implementation CommandView_LeftBtn

- (instancetype)initWithFrame:(CGRect)frame WithImgName:(NSString *)imgNorName WithImageSelName:(NSString *)selImgName WithTitle:(NSString *)title {
    if (self == [super initWithFrame:frame]) {
        [self initViews];
        [self initFrames];
        [_iconImg setBackgroundImage:[UIImage imageNamed:imgNorName] forState:0];
        [_iconImg setBackgroundImage:[UIImage imageNamed:selImgName] forState:UIControlStateSelected];

        _titleLab.text = title;

    }
    return self;
}

- (void)initFrames {
    
    [_iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.height.width.equalTo(@(20*IPADSCALE));
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconImg.mas_bottom).offset(2);
        make.height.equalTo(@(13.5*IPADSCALE));
        make.width.equalTo(self);
        make.left.equalTo(self);
    }];
    _titleLab.textAlignment = NSTextAlignmentCenter;
    _titleLab.font = ZYQFONT(18);
//    _titleLab.textColor = RGBColor(13, 157, 219);
//    _titleLab.textColor = RGBColor(255, 255, 255);
    
    [_lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.height.equalTo(self);
        make.width.equalTo(@4);
    }];
    _lineLab.backgroundColor = RGBColor(13, 157, 219);
    
    
    
    

}
- (void)initViews {
    _iconImg = [UIButton new];
    _titleLab = [UILabel new];
    _lineLab = [UILabel new];
    _iconImg.userInteractionEnabled = NO;
    
    [self addSubview:_iconImg];
    [self addSubview:_titleLab];
    [self addSubview:_lineLab];

}


- (void)setSelected:(BOOL)selected {
    _iconImg.selected = selected;
    _lineLab.hidden = !selected;
    if(selected == YES){
        _titleLab.textColor = RGBColor(13, 157, 219);

    }else{
        _titleLab.textColor = RGBColor(99, 89, 89);
    }
}

@end
